//
//  JNMainViewController.swift
//  SinaWeibo
//
//  Created by 9264 on 16/9/19.
//  Copyright © 2016年 LY9264. All rights reserved.
//

import UIKit

class JNMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // 设置只读属性的值
        let jnTabBar = JNTabBar()
        setValue(jnTabBar, forKey: "tabBar")
        
        jnTabBar.composeButtonClosure = {
            print("就是你咧")
        }
        
        //tabBar字体和图片颜色
        UITabBar.appearance().tintColor = UIColor.orange
        
        addChildViewController(childController: JNHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(childController: JNMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(childController: JNDiscoverTableViewController(), title: "搜索", imageName: "tabbar_discover")
        addChildViewController(childController: JNProfileTableViewController(), title: "我的", imageName: "tabbar_profile")
        
        
    }
    //MARK:- 设置 tabBar 时调用
    func addChildViewController(childController: UIViewController ,title: String ,imageName: String){
        
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        //nav 和 tabBar 的 title
        childController.title = title
        
        let nav = UINavigationController(rootViewController: childController)
        
        addChildViewController(nav)
        
        
    }


}
